import smsApi from '@/api/declaration/smsApi'
import httpRequest from '@/config/axios/httpRequest'
import {
  CreateSmsTemplateReq,
  CreateSmsTemplateResp,
  DeleteSmsTemplateReq,
  ExportSmsTemplateReq,
  QuerySmsChannelDetailResp,
  QuerySmsTemplateDetailReq,
  QuerySmsTemplatePageReq,
  QuerySmsTemplatePageResp,
  SendSmsReq,
  SendSmsResp,
  UpdateSmsTemplateReq,
  UpdateSmsTemplateResp
} from '@/models/system/SmsModel'

// 查询短信模板列表
export const getSmsTemplatePage = async (params: QuerySmsTemplatePageReq) => {
  return await httpRequest.get<QuerySmsTemplatePageResp>(smsApi.QuerySmsTemplatePage, { params })
}

// 查询短信模板详情
export const getSmsTemplate = async (params: QuerySmsTemplateDetailReq) => {
  return await httpRequest.get<QuerySmsChannelDetailResp>(smsApi.QuerySmsTemplateDetail, { params })
}

// 新增短信模板
export const createSmsTemplate = async (data: CreateSmsTemplateReq) => {
  return await httpRequest.post<CreateSmsTemplateResp>(smsApi.CreateSmsTemplate, data)
}

// 修改短信模板
export const updateSmsTemplate = async (data: UpdateSmsTemplateReq) => {
  return await httpRequest.put<UpdateSmsTemplateResp>(smsApi.UpdateSmsTemplate, data)
}

// 删除短信模板
export const deleteSmsTemplate = async (params: DeleteSmsTemplateReq) => {
  return await httpRequest.delete(smsApi.DeleteSmsTemplate, { params })
}

// 导出短信模板
export const exportSmsTemplate = async (param: ExportSmsTemplateReq) => {
  return await httpRequest.download(smsApi.ExportSmsTemplateExcel, {
    params: param,
    responseType: 'blob'
  })
}

// 发送短信
export const sendSms = async (data: SendSmsReq) => {
  return await httpRequest.post<SendSmsResp>(smsApi.SendSms, data)
}
